package cn.z2huo.demo.kafka.apache.producer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.RecordMetadata;

/**
 * <p>
 *
 * @author z2huo
 */
@Slf4j
public class AsyncSendMessageCallback implements Callback {

    @Override
    public void onCompletion(RecordMetadata metadata, Exception exception) {
        if (exception == null) {
            log.info("send message to topic {}, partition {} with offset {}", metadata.topic(), metadata.partition(), metadata.offset());
        } else {
            log.error("send message to topic {} failed", metadata.topic(), exception);
        }
    }

}
